<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!--企业数据-->
      <el-col :span="4" :xs="24">
        <div class="head-container">
          <el-input v-model="deptName" placeholder="请输入名称" clearable size="small" prefix-icon="el-icon-search"
            style="margin-bottom: 20px" />
        </div>
        <div class="head-containers">
          <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false"
            :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all highlight-current
            @node-click="handleNodeClick" />
        </div>
      </el-col>
      <!--小区数据-->
      <el-col :span="20" :xs="24">
        <el-card class="box-card">
          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
            label-width="68px">
            <el-form-item label="小区名称" prop="userName">
              <el-input v-model="queryParams.userName" placeholder="请输入小区名称" clearable style="width: 240px"
                @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="营业点" prop="status">
              <el-select v-model="queryParams.nickName" filterable placeholder="请选择">
                <el-option label="营业点一" value="1"> </el-option>
                <el-option label="营业点二" value="2"> </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="联系电话" prop="userName">
              <el-input v-model="queryParams.userName" type="number" placeholder="请输入联系电话" clearable style="width: 240px"
                @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>

          <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
              <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
                v-hasPermi="['fileManagement:civilArchivesQuery:export']">导出</el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
          </el-row>

          <el-table v-loading="loading" :data="userList" border>
            <el-table-column label="单位名称" align="center" key="userName" prop="userName" :show-overflow-tooltip="true" />
            <el-table-column label="区域名称" align="center" key="userName" prop="userName" :show-overflow-tooltip="true" />
            <el-table-column label="小区名称" align="center" key="userName" prop="userName" :show-overflow-tooltip="true" />
            <el-table-column label="营业点" align="center" key="userName" prop="userName" :show-overflow-tooltip="true" />
            <el-table-column label="负责人" align="center" key="deptName" prop="dept.deptName"
              :show-overflow-tooltip="true" />
            <el-table-column label="联系电话" align="center" key="deptName" prop="dept.deptName"
              :show-overflow-tooltip="true" />
            <el-table-column label="余额提醒阈值" align="center" key="deptName" prop="dept.deptName"
              :show-overflow-tooltip="true" width="100" />
            <el-table-column label="短信提醒号码" align="center" key="deptName" prop="dept.deptName"
              :show-overflow-tooltip="true" width="100" />
            <el-table-column label="欠费关阀" align="center" key="deptName" prop="dept.deptName"
              :show-overflow-tooltip="true" />
            <el-table-column label="缴费开阀" align="center" key="deptName" prop="dept.deptName"
              :show-overflow-tooltip="true" />
            <el-table-column label="收费月份" align="center" key="deptName" prop="dept.deptName"
              :show-overflow-tooltip="true" />
            <el-table-column label="账单日" align="center" key="deptName" prop="dept.deptName"
              :show-overflow-tooltip="true" />
            <el-table-column label="自动发送短信" align="center" key="deptName" prop="dept.deptName"
              :show-overflow-tooltip="true" width="100" />
            <el-table-column label="账户余额" align="center" key="deptName" prop="dept.deptName"
              :show-overflow-tooltip="true" />
          </el-table>

          <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize" @pagination="getList" />
        </el-card>
        <el-card class="box-card" style="margin-top: 10px">
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="账户详情" name="1">
              <table border class="tablex">
                <tbody>
                  <tr>
                    <td class="lables">客户ID</td>
                    <td>我是值</td>
                    <td class="lables">客户卡号</td>
                    <td>我是值</td>
                  </tr>
                  <tr>
                    <td class="lables">单位名称</td>
                    <td>我是值</td>
                    <td class="lables">营业点</td>
                    <td>我是值</td>
                  </tr>
                  <tr>
                    <td class="lables">区域名称</td>
                    <td>我是值</td>
                    <td class="lables">小区名称</td>
                    <td>我是值</td>
                  </tr>
                  <tr>
                    <td class="lables">负责人</td>
                    <td>我是值</td>
                    <td class="lables">联系电话</td>
                    <td>我是值</td>
                  </tr>
                  <tr>
                    <td class="lables">身份证号</td>
                    <td>我是值</td>
                    <td class="lables">地址(车间)</td>
                    <td>我是值</td>
                  </tr>
                  <tr>
                    <td class="lables">账户余额</td>
                    <td>我是值</td>
                    <td class="lables">余额更新时间</td>
                    <td>我是值</td>
                  </tr>
                  <tr>
                    <td class="lables">余额提醒阈值</td>
                    <td>我是值</td>
                    <td class="lables">短信提醒号码</td>
                    <td>我是值</td>
                  </tr>
                  <tr>
                    <td class="lables">欠费关阀</td>
                    <td>我是值</td>
                    <td class="lables">缴费开阀</td>
                    <td>我是值</td>
                  </tr>
                  <tr>
                    <td class="lables">收费月份</td>
                    <td>我是值</td>
                    <td class="lables">账单日</td>
                    <td>我是值</td>
                  </tr>
                  <tr>
                    <td class="lables">自动发送短信</td>
                    <td>我是值</td>
                  </tr>
                </tbody>
              </table>
            </el-tab-pane>
            <el-tab-pane label="表记信息展示" name="2">
              <el-table :data="tableData" border style="width: 100%">
                <el-table-column type="index" width="50" label="序号" align="center">
                </el-table-column>
                <el-table-column prop="date" label="设备名称" align="center"></el-table-column>
                <el-table-column prop="date" label="表具类型" align="center">
                </el-table-column>
                <el-table-column prop="name" label="表号" align="center">
                </el-table-column>
                <el-table-column prop="address" label="基表底数" align="center"></el-table-column>
                <el-table-column prop="date" label="用气类型" align="center">
                </el-table-column>
                <el-table-column prop="name" label="单价" align="center">
                </el-table-column>
                <el-table-column prop="date" label="气表品牌" align="center">
                </el-table-column>
                <el-table-column prop="name" label="基表厂家" align="center">
                </el-table-column>
                <el-table-column prop="date" label="客户类型" align="center">
                </el-table-column>
                <el-table-column prop="name" label="同步到IOT平台" align="center" width="120">
                </el-table-column>
                <el-table-column prop="date" label="进气方向" align="center">
                </el-table-column>
                <el-table-column label="表计状态" align="center" prop="meterStatus" width="120">
                  <template slot-scope="scope">
                    <span v-if="scope.row.meterStatus == 1">待安装</span>
                    <span v-if="scope.row.meterStatus == 2">正常</span>
                    <span v-if="scope.row.meterStatus == 3">已拆卸</span>
                  </template>

                </el-table-column>
                <el-table-column prop="name" label="安装日期" align="center">
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="运维操作日志" name="3">
              <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
                label-width="68px">
                <el-form-item label="数据日期">
                  <el-date-picker v-model="value2" type="daterange" align="right" unlink-panels range-separator="至"
                    start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions">
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="状态">
                  <el-radio-group v-model="radio" style="margin-left: 30px">
                    <el-radio :label="1">停用</el-radio>
                    <el-radio :label="2">启用</el-radio>
                    <el-radio :label="3">拆表</el-radio>
                    <el-radio :label="4">销户</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-form>
              <el-table :data="tableData2" border style="width: 100%">
                <el-table-column type="index" width="50" label="序号" align="center">
                </el-table-column>
                <el-table-column prop="date" label="操作时间" align="center"></el-table-column>
                <el-table-column prop="date" label="操作原因" align="center">
                </el-table-column>
                <el-table-column prop="name" label="客户名称" align="center">
                </el-table-column>
                <el-table-column prop="address" label="客户编号" align="center"></el-table-column>
                <el-table-column prop="date" label="所属小区" align="center">
                </el-table-column>
                <el-table-column prop="name" label="客户地址" align="center">
                </el-table-column>
                <el-table-column prop="date" label="联系电话" align="center">
                </el-table-column>
                <el-table-column prop="name" label="负责人" align="center">
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="交易记录" name="4">
              <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
                label-width="68px">
                <el-form-item label="交易方式" prop="status">
                  <el-select v-model="queryParams.nickName" filterable placeholder="请选择">
                    <el-option label="缴费" value="1"> </el-option>
                    <el-option label="扣费" value="2"> </el-option>
                    <el-option label="冲正" value="3"> </el-option>
                    <el-option label="退费" value="4"> </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="交易时间">
                  <el-date-picker v-model="value3" type="daterange" align="right" unlink-panels range-separator="至"
                    start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions">
                  </el-date-picker>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" icon="el-icon-search" size="mini">查询</el-button>
                </el-form-item>
              </el-form>
              <el-table :data="tableData3" border style="width: 100%">
                <el-table-column prop="date" label="交易方式" align="center"></el-table-column>
                <el-table-column prop="date" label="交易金额(元)" align="center">
                </el-table-column>
                <el-table-column prop="name" label="账户余额(元)" align="center">
                </el-table-column>
                <el-table-column prop="address" label="用量合计(m³)" align="center"></el-table-column>
                <el-table-column prop="date" label="抄表起码" align="center">
                </el-table-column>
                <el-table-column prop="name" label="抄表起码日期" align="center">
                </el-table-column>
                <el-table-column prop="date" label="抄表止码" align="center">
                </el-table-column>
                <el-table-column prop="name" label="抄表止码日期" align="center">
                </el-table-column>
                <el-table-column prop="name" label="支付方式" align="center">
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="日冻结数据补录" name="5">
              <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
                label-width="68px">
                <el-form-item label="数据日期">
                  <el-date-picker v-model="value3" type="daterange" align="right" unlink-panels range-separator="至"
                    start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions">
                  </el-date-picker>
                </el-form-item>
              </el-form>
              <el-table :data="tableData4" border style="width: 100%">
                <el-table-column type="index" width="50" label="序号" align="center">
                </el-table-column>
                <el-table-column prop="date" label="数据日期" align="center"></el-table-column>
                <el-table-column prop="date" label="瞬时流量" align="center">
                </el-table-column>
                <el-table-column prop="name" label="温度" align="center">
                </el-table-column>
                <el-table-column prop="address" label="压强" align="center"></el-table-column>
                <el-table-column prop="date" label="累计工作时间" align="center">
                </el-table-column>
                <el-table-column prop="name" label="实时时间" align="center">
                </el-table-column>
                <el-table-column prop="date" label="信号强度" align="center">
                </el-table-column>
                <el-table-column prop="name" label="数据录入标识" align="center">
                </el-table-column>
                <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width">
                  <template slot-scope="scope">
                    <el-button size="mini" type="text">补录</el-button>
                    <el-button size="mini" type="text">补采</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="安检记录" name="6">
              <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
                label-width="68px">
                <el-form-item label="数据日期">
                  <el-date-picker v-model="value3" type="daterange" align="right" unlink-panels range-separator="至"
                    start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions">
                  </el-date-picker>
                </el-form-item>
              </el-form>
              <el-table :data="tableData5" border style="width: 100%">
                <el-table-column type="index" width="50" label="序号" align="center">
                </el-table-column>
                <el-table-column prop="date" label="计划名称" align="center"></el-table-column>
                <el-table-column prop="date" label="计划类型" align="center">
                </el-table-column>
                <el-table-column prop="name" label="安检状态" align="center">
                </el-table-column>
                <el-table-column prop="address" label="生成回访单" align="center"></el-table-column>
                <el-table-column prop="date" label="安检员" align="center">
                </el-table-column>
                <el-table-column prop="name" label="安检时间" align="center">
                </el-table-column>
                <el-table-column prop="date" label="开始时间" align="center">
                </el-table-column>
                <el-table-column prop="name" label="结束时间" align="center">
                </el-table-column>
                <el-table-column prop="name" label="安检记录" align="center">
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="维修记录" name="7">
              <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
                label-width="68px">
                <el-form-item label="数据日期">
                  <el-date-picker v-model="value3" type="daterange" align="right" unlink-panels range-separator="至"
                    start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions">
                  </el-date-picker>
                </el-form-item>
              </el-form>
              <el-table :data="tableData6" border style="width: 100%">
                <el-table-column type="index" width="50" label="序号" align="center">
                </el-table-column>
                <el-table-column prop="date" label="工单来源" align="center"></el-table-column>
                <el-table-column prop="date" label="工单状态" align="center">
                </el-table-column>
                <el-table-column prop="name" label="提报人" align="center">
                </el-table-column>
                <el-table-column prop="address" label="提报时间" align="center"></el-table-column>
                <el-table-column prop="date" label="提报内容" align="center">
                </el-table-column>
                <el-table-column prop="name" label="维修人" align="center">
                </el-table-column>
                <el-table-column prop="date" label="维修时间" align="center">
                </el-table-column>
                <el-table-column prop="name" label="备注" align="center">
                </el-table-column>
              </el-table>
            </el-tab-pane>
          </el-tabs>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {
  listUser,
  getUser,
  delUser,
  addUser,
  updateUser,
  deptTreeSelect,
} from "@/api/system/user";
import { getToken } from "@/utils/auth";

export default {
  name: "IndustrialArchivesQuery",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 小区表格数据
      userList: null,
      // 弹出层标题
      title: "",
      //表计弹出层标题
      title2: "",
      // 企业树选项
      deptOptions: undefined,
      // 企业名称
      deptName: undefined,
      // 表单参数
      form: {},
      defaultProps: {
        children: "children",
        label: "label",
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: undefined,
        phonenumber: undefined,
        status: undefined,
        deptId: undefined,
      },
      // 表单校验
      rules: {
        userName: [
          { required: true, message: "小区名称不能为空", trigger: "blur" },
          {
            min: 2,
            max: 20,
            message: "小区名称长度必须介于 2 和 20 之间",
            trigger: "blur",
          },
        ],
        nickName: [
          { required: true, message: "小区昵称不能为空", trigger: "blur" },
        ],
      },
      activeName: "1",
      tableData: [{}],
      tableData2: [{}],
      tableData3: [{}],
      tableData4: [{}],
      tableData5: [{}],
      tableData6: [{}],
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      value2: "",
      radio: 1,
      value3: "",
    };
  },
  watch: {
    // 根据名称筛选企业树
    deptName(val) {
      this.$refs.tree.filter(val);
    },
  },
  created() {
    this.getList();
    this.getDeptTree();
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab, event);
    },
    /** 查询小区列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams)).then((response) => {
        this.userList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 查询企业下拉树结构 */
    getDeptTree() {
      deptTreeSelect().then((response) => {
        this.deptOptions = response.data;
      });
    },
    // 筛选节点
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    // 节点单击事件
    handleNodeClick(data) {
      this.queryParams.deptId = data.id;
      this.handleQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.$refs.tree.setCurrentKey(null);
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/user/export",
        {
          ...this.queryParams,
        },
        `user_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style lang="scss" scoped>
.head-containers {
  width: 200px;
  overflow: auto;

  .el-tree {
    min-width: 100%;
    display: inline-block !important;
  }
}

.tablex {
  width: 100%;
  border-collapse: collapse;
  border-color: #ebeef5;

  td {
    width: 25%;
    padding: 10px;
    color: #606266;
    font-size: 14px;
  }

  .lables {
    background: rgba(150, 154, 184, 0.05);
    text-align: right;
  }
}
</style>
